package com.info.zhiduoduo.weixin.controller;

import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.complaint.ComplaintDto;
import com.info.zhiduoduo.weixin.formbean.complaint.ComplaintFormBean;
import com.info.zhiduoduo.weixin.formbean.complaint.ComplaintListFormBean;
import com.info.zhiduoduo.weixin.service.ComplaintService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/complaint")
@Api(tags = "用户投诉")
public class ComplaintController {

	@Autowired
	ComplaintService complaintService;

	@ZddLog(name = "提交投诉")
	@ApiOperation("提交投诉")
	@PostMapping("/submitComplaint")
	public SmartResult submitComplaint(@Valid @RequestBody BaseSimpleFormBean<ComplaintFormBean> formBean) {
		return complaintService.submitComplaint(formBean);
	}

	@ApiOperation("获取用户投诉列表，支持分页")
	@PostMapping("/complaintList")
	public SmartResult<ComplaintDto> getComplaintList(@RequestBody BaseSimpleFormBean<ComplaintListFormBean> formBean) {
		return complaintService.getComplaintList(formBean);
	}

	@ApiOperation(value = "获取投诉详情", notes = "reqdata传投诉id")
	@PostMapping("/detail")
	public SmartResult<ComplaintDto> getDetail(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return complaintService.getDetail(formBean);
	}
}
